<?php
if(isset($form['#village'])&& !empty($form['#village'])) {
    echo get_template_header_info($form['#village'],"village");
}
?>
<div class="hp-tab-newprd">
    <?php if(!empty($_GET['farmer_id'])){?>
        <img style="margin-left: 75px;" src="<?php echo base_path()?>sites/all/themes/tweme/images/images/farmer.png"/>
    <?php }else if(!empty($_GET['village_id'])){ ?>
        <img style="margin-left:85px;" src="<?php echo base_path()?>sites/all/themes/tweme/images/images/village.png"/>
    <?php }?>
    <ul class="j-sw-nav">
        <?php if(isset($form['#village'])&& !empty($form['#village'])){?>
            <?php echo get_tab($form['#village'],'overview',"village"); ?>
        <?php }?>
    </ul>
    <div class="newprd-s1">
        <div class="table-div">
            <div class="fieldset-div">
                <div class="fieldset-title">村落信息</div>
                <?php //foreach($form['farmer_info']['plant_info'] as $key => $val){
                        $village_info = $form['#village_info']['village_info'];
                ?>
                    <div class="farmer-field">
                        <div class="farmer-field-div">
                            <span>村落名称:</span>
                            <span><?php echo $village_info->name;?></span>
                        </div>
                        <div class="farmer-field-div">
                            <span>经销商:</span>
                            <span><?php echo $village_info->distributor_name;?></span>
                        </div>
                    </div>

                <div class="farmer-field">
                    <div class="farmer-field-div second">
                        <span>人口数量:</span>
                        <span><?php echo $village_info->population;?></span>
                    </div>
                    <div class="farmer-field-div second">
                        <span>人均收入（元）:</span>
                        <span><?php echo $village_info->income_average;?></span>
                    </div>
                    <div class="farmer-field-div second">
                        <span>耕地面积（亩）:</span>
                        <span><?php echo $village_info->farm_area;?></span>
                    </div>

                </div>
                <div class="farmer-field">
                    <div class="farmer-field-div second">
                        <span>土壤条件:</span>
                        <span><?php echo $village_info->soil_condition;?></span>
                    </div>
                    <div class="farmer-field-div second">
                        <span>专项活动:</span>
                        <span><?php echo $village_info->special_activites_name;?></span>
                    </div>
                </div>
                <div style="clear: both;"></div>
            </div>
            <?php
            $max_length = 10;
            $max_length_long = 20;
            $max_length_short = 10;

            ?>
            <?php if(user_access('view own village_activity')){ ?>
            <div class="fieldset-div village-activity-info-div <?php echo count($form['#village_info']['village_activity_info']);?> village-overview-item-div">
                <div class="fieldset-title">村落活动<div style="float: right"><span class="village-datacount 4">4条</span><span class="village-datacount 8">8条</span><span class="village-datacount 12">12条</span><span class="village-datacount 16">16条</span><span class="village-datacount 20">20条</span></div></div>
                <?php foreach($form['#village_info']['village_activity_info'] as $key => $val){ ?>
                    <div class="fieldset-content">
                        <table class="fieldset-table">
                            <tbody>

                                <tr>
                                    <td class="fieldset-tr-title">活动日期:</td>
                                    <td><?php echo $val->date;?></td>
                                </tr>

                                <tr>
                                    <td class="fieldset-tr-title">经销商:</td>
                                    <td><?php
                                        if(mb_strwidth($val->distributor_name)>$max_length_long){
                                            $val->distributor_name = mb_substr($val->distributor_name,0,$max_length_long, 'utf-8').'...';
                                        }
                                        echo $val->distributor_name;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">标题:</td>
                                    <td class="fixed-size-middle"><?php
                                        if(mb_strwidth($val->title)>$max_length_long){
                                            $val->title = mb_substr($val->title,0,$max_length_long, 'utf-8').'...';
                                        }
                                        echo $val->title;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">专项活动:</td>
                                    <td class="fixed-size-middle"><?php
                                        if(mb_strwidth($val->special_activities_tile)>$max_length_long){
                                            $val->special_activities_tile = mb_substr($val->special_activities_tile,0,$max_length_long, 'utf-8').'...';
                                        }
                                        echo $val->special_activities_tile;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">活动内容:</td>
                                    <td class="fixed-size-middle"><?php
                                        if(mb_strwidth($val->body)>$max_length_long){
                                            $val->body = mb_substr($val->body,0,$max_length_long, 'utf-8').'...';
                                        }
                                        echo $val->body;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">参与人员:</td>
                                    <td class="fixed-size-middle"><?php
                                        if(mb_strwidth($val->attendee)>$max_length_long){
                                            $val->attendee = mb_substr($val->attendee,0,$max_length_long, 'utf-8').'...';
                                        }
                                        echo $val->attendee;?></td>
                                </tr>

                            </tbody>
                        </table>

                    </div>
                <?php }?>
                <div style="clear: both;"></div>
            </div>
            <?php }?>
            <?php if(user_access('view own farmer')){ ?>
            <div class="fieldset-div farmer-info-div <?php echo count($form['#village_info']['village_farmer_info']);?> village-overview-item-div">
                <div class="fieldset-title">农户信息<div style="float: right"><span class="village-datacount 4">4条</span><span class="village-datacount 8">8条</span><span class="village-datacount 12">12条</span><span class="village-datacount 16">16条</span><span class="village-datacount 20">20条</span></div></div>
                <?php foreach($form['#village_info']['village_farmer_info'] as $key => $val){ ?>
                    <div class="fieldset-content soil-field">
                        <table class="fieldset-table">
                            <tbody>
                            <tr>
                                <td class="fieldset-tr-title">姓名:</td>
                                <td><?php echo $val->farmer_name;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">性别:</td>
                                <td><?php echo $val->gender;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">手机:</td>
                                <td><?php echo $val->cell;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">电话号码:</td>
                                <td><?php echo $val->phone;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">邮箱:</td>
                                <td><?php
                                    if(strlen($val->email)>$max_length){
                                        $val->email = mb_substr($val->email,0,$max_length-1, 'utf-8').'...';
                                    }
                                    echo $val->email;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">农户类型:</td>
                                <td><?php echo $val->type;?></td>
                            </tr>

                        </table>
                        <table class="fieldset-table">
                            <tbody>
                            <tr>
                                <td class="fieldset-tr-title">耕地面积:</td>
                                <td><?php echo $val->farm_area;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">土壤种类:</td>
                                <td><?php echo $val->soil_type;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">肥沃程度:</td>
                                <td><?php echo $val->soil_fertility;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">经销商:</td>
                                <td><?php
                                    if(strlen($val->distributor_name)>$max_length/2){
                                        $val->distributor_name = mb_substr($val->distributor_name,0,$max_length/2-1, 'utf-8').'...';
                                    }
                                    echo $val->distributor_name;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">专项活动:</td>
                                <td><?php
                                    if(strlen($val->special_activities_title)>$max_length/2){
                                        $val->special_activities_title = mb_substr($val->special_activities_title,0,$max_length/2-1, 'utf-8').'...';
                                    }
                                    echo $val->special_activities_title;?></td>
                            </tr>
                            </tbody>
                            </tbody>
                        </table>

                    </div>
                <?php }?>
                <div style="clear: both;"></div>
            </div>
            <?php }?>
            <?php if(user_access('view own plant_info')){ ?>
            <div class="fieldset-div village-plant-info-div <?php echo count($form['#village_info']['village_plant_info']);?> village-overview-item-div">
                <div class="fieldset-title">种植信息<div style="float: right"><span class="village-datacount 4">4条</span><span class="village-datacount 8">8条</span><span class="village-datacount 12">12条</span><span class="village-datacount 16">16条</span><span class="village-datacount 20">20条</span></div></div>
                <?php foreach($form['#village_info']['village_plant_info'] as $key => $val){ ?>
                    <div class="fieldset-content gift-field">
                        <table class="fieldset-table">
                            <tbody>
                            <tr>
                                <td class="fieldset-tr-title">农户:</td>
                                <td><?php echo $val->farmer_name;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">作物:</td>
                                <td><?php echo $val->plant_name;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">种植品种:</td>
                                <td><?php echo $val->seed;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">种植面积:</td>
                                <td><?php echo $val->plant_area;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">一年生/多年生:</td>
                                <td><?php  if($val->perennial === 1){
                                        echo "一年生";
                                    }else{
                                        echo "多年生";
                                    } ?>
                                </td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">播种日期:</td>
                                <td><?php echo $val->sow_date;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">收获日期:</td>
                                <td><?php echo $val->harvest_date;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">株距（厘米）:</td>
                                <td><?php echo $val->plant_space;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">行距（厘米）:</td>
                                <td><?php echo $val->row_space;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">灌溉方式:</td>
                                <td><?php echo $val->irrigation;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">一般产量:</td>
                                <td><?php echo $val->general_yield;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">撒可富品种:</td>
                                <td><?php
                                    if(strlen($val->sacf)>$max_length){
                                        $val->sacf = mb_substr($val->sacf,0,$max_length-1, 'utf-8').'...';
                                    }
                                    echo $val->sacf;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">撒可富赠费量:</td>
                                <td><?php echo $val->sacf_fertilizer;?></td>
                            </tr>

                            </tbody>
                        </table>
                        <table class="fieldset-table">
                            <tbody>

                            <tr>
                                <td class="fieldset-tr-title">示范面积（亩）:</td>
                                <td><?php echo $val->demonstration_area;?></td>
                            </tr>


                            <tr>
                                <td class="fieldset-tr-title">种子开销:</td>
                                <td><?php echo $val->seed_cost;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">肥料开销:</td>
                                <td><?php echo $val->fertilizer_cost;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">农药开销:</td>
                                <td><?php echo $val->pesticide_cost;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">农机开销:</td>
                                <td><?php echo $val->machinery_cost;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">其他开销:</td>
                                <td><?php echo $val->others_cost;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">产品单价:</td>
                                <td><?php echo $val->unit_price;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">总投入:</td>
                                <td><?php echo $val->total_input;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">密度:</td>
                                <td><?php echo $val->density;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">收入:</td>
                                <td><?php echo $val->income;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">净收入:</td>
                                <td><?php echo $val->net_income;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">其他收益:</td>
                                <td><?php echo $val->other_yield;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">专项活动:</td>
                                <td><?php
                                    if(strlen($val->special_activities_title)>$max_length/2){
                                        $val->special_activities_title = mb_substr($val->special_activities_title,0,$max_length/2-1, 'utf-8').'...';
                                    }
                                    echo $val->special_activities_title;?></td>
                            </tr>

                            </tbody>
                        </table>
                    </div>
                <?php }?>
                <div style="clear: both;"></div>
            </div>
            <?php }?>

            <?php if(user_access('view own soil_info')){ ?>
                <div class="fieldset-div village-soil-info-div <?php echo count($form['#village_info']['village_soil_info']);?> village-overview-item-div">
                    <div class="fieldset-title">土壤信息<div style="float: right"><span class="village-datacount 4">4条</span><span class="village-datacount 8">8条</span><span class="village-datacount 12">12条</span><span class="village-datacount 16">16条</span><span class="village-datacount 20">20条</span></div></div>
                    <?php foreach($form['#village_info']['village_soil_info'] as $key => $val){ ?>
                        <div class="fieldset-content gift-field">
                            <table class="fieldset-table">
                                <tbody>
                                <tr>
                                    <td class="fieldset-tr-title">农户:</td>
                                    <td><?php echo $val->farmer_name;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">送样地点:</td>
                                    <td><?php
                                        if(strlen($val->location)>$max_length/2){
                                            $val->location = mb_substr($val->location,0,$max_length/2-1, 'utf-8').'...';
                                        }
                                        echo $val->location;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">送样人:</td>
                                    <td><?php echo $val->sampler;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">专项活动:</td>
                                    <td><?php
                                        if(strlen($val->special_activities_title)>$max_length/2){
                                            $val->special_activities_title = mb_substr($val->special_activities_title,0,$max_length/2-1, 'utf-8').'...';
                                        }
                                        echo $val->special_activities_title;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">采样日期:</td>
                                    <td><?php echo $val->sample_date;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">目标产量:</td>
                                    <td><?php echo $val->target_yield;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">前茬作物:</td>
                                    <td><?php echo $val->pre_plant_name;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">当季作物:</td>
                                    <td><?php echo $val->rec_plant_name;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">氮(mg/L):</td>
                                    <td><?php echo $val->nitrogen;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">磷(mg/L):</td>
                                    <td><?php echo $val->phosphorus;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">钾(mg/L):</td>
                                    <td><?php echo $val->potassium;?></td>
                                </tr>
                                </tbody>
                            </table>
                            <table class="fieldset-table">
                                <tbody>

                                <tr>
                                    <td class="fieldset-tr-title">有机质(mg/L):</td>
                                    <td><?php echo $val->organicmatter;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">PH值:</td>
                                    <td><?php echo $val->ph;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">钙(mg/L):</td>
                                    <td><?php echo $val->calcium;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">镁(mg/L):</td>
                                    <td><?php echo $val->magnesium;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">硫(mg/L):</td>
                                    <td><?php echo $val->sulfur;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">锌(mg/L):</td>
                                    <td><?php echo $val->zinc;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">铜(mg/L):</td>
                                    <td><?php echo $val->copper;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">铁(mg/L):</td>
                                    <td><?php echo $val->iron;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">硼(mg/L):</td>
                                    <td><?php echo $val->boron;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">锰(mg/L):</td>
                                    <td><?php echo $val->manganese;?></td>
                                </tr>


                                </tbody>
                            </table>
                        </div>
                    <?php }?>
                    <div style="clear: both;"></div>
                </div>
            <?php }?>
            <?php if(user_access('view own fertilizer_case')){ ?>
            <div class="fieldset-div village-fertilizer-info-div <?php echo count($form['#village_info']['village_fertilizer_case_info']);?> village-overview-item-div">
                <div class="fieldset-title">施肥案例<div style="float: right"><span class="village-datacount 4">4条</span><span class="village-datacount 8">8条</span><span class="village-datacount 12">12条</span><span class="village-datacount 16">16条</span><span class="village-datacount 20">20条</span></div></div>
                <?php foreach($form['#village_info']['village_fertilizer_case_info'] as $key => $val){ ?>
                    <div class="fieldset-content fertilizer-field">
                        <table class="fieldset-table">
                            <tbody>
                            <tr>
                                <td class="fieldset-tr-title">农户:</td>
                                <td><?php echo $val->farmer_name;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">专项活动:</td>
                                <td><?php echo $val->special_activities_title;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">农作物:</td>
                                <td><?php echo $val->plant_name;?></td>
                            </tr>
                            </tbody>
                        </table>

<!--                        <table class="fieldset-table">-->
<!--                            <tbody>-->
<!---->
<!--                            <tr>-->
                        <div style="clear:both; height: 20px; overflow: hidden" class="fieldset-tr-title">
<!--                                <td class="fieldset-tr-title">-->
<!--                                    效果描述:-->
<!--<!--                                </td><td>-->
<!--                                --><?php //echo $val->effect_desc;?>
<!--                            </td>-->
<!--                            </tr>-->
<!--                            </tbody>-->
<!--                        </table>-->
                            </div>
                    </div>
                <?php }?>
                <div style="clear: both;"></div>
            </div>
            <?php }?>
            <?php if(user_access('view own revisit')){ ?>
            <div class="fieldset-div village-revisit-info-div <?php echo count($form['#village_info']['village_revisit_info']);?> village-overview-item-div">
                <div class="fieldset-title">回访记录<div style="float: right"><span class="village-datacount 4">4条</span><span class="village-datacount 8">8条</span><span class="village-datacount 12">12条</span><span class="village-datacount 16">16条</span><span class="village-datacount 20">20条</span></div></div>
                <?php foreach($form['#village_info']['village_revisit_info'] as $key => $val){ ?>
                    <div class="fieldset-content revisit-field">
                        <table class="fieldset-table">
                            <tbody>
                            <tr>
                                <td class="fieldset-tr-title">农户:</td>
                                <td><?php echo $val->farmer_name;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">回访日期:</td>
                                <td><?php echo $val->visit_date;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">单产量:</td>
                                <td><?php echo $val->unit_yield;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">纯收益:</td>
                                <td><?php echo $val->net_income;?></td>
                            </tr>
                            </tbody>
                        </table>

                        <table class="fieldset-table">
                            <tbody>
                            <tr>
                                <td class="fieldset-tr-title">作物:</td>
                                <td><?php echo $val->plant_name;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">对照产量:</td>
                                <td><?php echo $val->contrast_yield;?></td>
                            </tr>
                            <tr>
                                <td class="fieldset-tr-title">对照收益:</td>
                                <td><?php echo $val->contrast_income;?></td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                <?php }?>
                <div style="clear: both;"></div>
            </div>
            <?php }?>
            <?php if(user_access('view own plant_measure')){ ?>
            <div class="fieldset-div measure-info-div <?php echo count($form['#village_info']['village_plant_measure_info']);?> village-overview-item-div">
                <div class="fieldset-title">田间测产<div style="float: right"><span class="village-datacount 4">4条</span><span class="village-datacount 8">8条</span><span class="village-datacount 12">12条</span><span class="village-datacount 16">16条</span><span class="village-datacount 20">20条</span></div></div>
                <?php foreach($form['#village_info']['village_plant_measure_info'] as $key => $val){ ?>
                    <div class="fieldset-content measure-field">
                        <table class="fieldset-table">
                            <tbody>
                            <tr>
                                <td class="fieldset-tr-title">测产日期:</td>
                                <td><?php echo $val->date;?></td>
                            </tr>
                            </tbody>
                        </table>

                        <table class="fieldset-table">
                            <tbody>
                            <tr>
                                <td class="fieldset-tr-title">农作物:</td>
                                <td><?php echo $val->plant_name;?></td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                <?php }?>
                <div style="clear: both;"></div>
            </div>
            <?php }?>
            <div style="clear: both;"></div>
     </div>
    </div>
</div>

<?php print drupal_render_children($form); ?>
